#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 2e5 + 5;

int n, m;
int a[N];
struct Node {
  double s1, s2;  // sin && cos
  ll d;
} tr[N << 2];
#define s1(p) tr[p].s1
#define s2(p) tr[p].s2
#define d(p) tr[p].d

void pushup(int p) {
  s1(p) = s1(p << 1) + s1(p << 1 | 1);
  s2(p) = s2(p << 1) + s2(p << 1 | 1);
}
void build(int p, int l, int r) {
  d(p) = 0;
  if (l == r) {
    s1(p) = sin(a[l]), s2(p) = cos(a[l]);
    return;
  }
  int mid = (l + r) >> 1;
  build(p << 1, l, mid);
  build(p << 1 | 1, mid + 1, r);
  pushup(p);
}
void addtag(ll k, int p) {
  d(p) += k;
  double x = s1(p) * cos(k) + s2(p) * sin(k);
  double y = s2(p) * cos(k) - s1(p) * sin(k);
  s1(p) = x;
  s2(p) = y;
}
void pushdown(int p) {
  if (d(p)) {
    addtag(d(p), p << 1);
    addtag(d(p), p << 1 | 1);
    d(p) = 0;
  }
}
void update(int L, int R, ll k, int p, int l, int r) {
  if (L <= l && R >= r) {
    addtag(k, p);
    return;
  }
  pushdown(p);
  int mid = (l + r) >> 1;
  if (L <= mid) update(L, R, k, p << 1, l, mid);
  if (R > mid) update(L, R, k, p << 1 | 1, mid + 1, r);
  pushup(p);
}
double query(int L, int R, int p, int l, int r) {
  if (L <= l && R >= r) return s1(p);
  pushdown(p);
  int mid = (l + r) >> 1;
  double res = 0;
  if (L <= mid) res += query(L, R, p << 1, l, mid);
  if (R > mid) res += query(L, R, p << 1 | 1, mid + 1, r);
  return res;
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n;
  rep(i, 1, n) cin >> a[i];
  build(1, 1, n);
  cin >> m;
  while (m--) {
    int op, l, r, k;
    cin >> op >> l >> r;
    if (op == 1) cin >> k;
    if (op == 1)
      update(l, r, k, 1, 1, n);
    else
      cout << fixed << setprecision(1) << query(l, r, 1, 1, n) << endl;
  }
  return 0;
}